package com.lxl.testHd.etl.two;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * @author ：e_lixilin
 * @date ：2022/2/22 9:47
 * @description：
 * @modified By：
 */
public class ProvinceGroup extends WritableComparator {
    public ProvinceGroup() {
        super(CarInfo.class,true);
    }

    //具体的“欺骗”策略：在判断两个CarInfoBean是否相同时，只判断CarInfoBean中carPlate属性的第一个字符（即车牌号上的“省份”）
    @Override
    public int compare(WritableComparable carType1, WritableComparable carType2) {
        CarInfo c1	= 	(CarInfo)carType1 ;
        CarInfo c2  = 	(CarInfo)carType2 ;
        String car1Province = c1.getCarPlate().substring(0,1) ;
        String car2Province = c2.getCarPlate().substring(0,1) ;
        return car1Province.compareTo(car2Province);
    }
}
